#region Using

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;

using Gizmox.WebGUI.Common;
using Gizmox.WebGUI.Forms;
using Agresso.Interface.Layer.Domain;
using Agresso.Interface.Layer.Service;

#endregion

namespace Agresso.Interface.Layer.Web
{
    public partial class SoftmarResponsibleUserForm : Form
    {
        ResponsibleUser m_ResponsibleUser;
        ResponsibleUserService m_ResponsibleUserService;
        UserControlSoftmarResponsibleUserMapping m_parent;

        public SoftmarResponsibleUserForm(ResponsibleUser agent, UserControlSoftmarResponsibleUserMapping parent)
        {
            InitializeComponent();
            Text = "Update User Map";
            m_ResponsibleUserService = new ResponsibleUserService();
            m_parent = parent;
            m_ResponsibleUser = agent;
            textBoxSoftmarUser.Text = m_ResponsibleUser.softmar_user;
            textBoxAgressoUser.Text = m_ResponsibleUser.agresso_user;
        }

        private void button1OK_Click(object sender, EventArgs e)
        {
            updateUser();
            this.Close();
        }

        private void updateUser()
        {
            m_ResponsibleUser.agresso_user = textBoxAgressoUser.Text;
            m_ResponsibleUserService.UpdateResponsibleUser(m_ResponsibleUser);
            m_parent.UpdateSelectedItem(m_ResponsibleUser);
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void buttonApply_Click(object sender, EventArgs e)
        {
            updateUser();
            buttonApply.Enabled = false;
        }

        private void DADeskVesselForm_Load(object sender, EventArgs e)
        {
            textBoxAgressoUser.Focus();
        }

        private void activate_apply(object sender, KeyPressEventArgs e)
        {
            buttonApply.Enabled = true;
        }
    }
}